package com.invengo.module_robot.ui.fragment.advert.item;

import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;

import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.invengo.module_robot.data.entity.AdvertBean;
import com.invengo.module_robot.ui.fragment.advert.AdvertViewModel;

import me.goldze.mvvmhabit.base.ItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.bus.BindingAction;
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent;
import me.goldze.mvvmhabit.utils.KLog;


/**
 * @author buoker
 * @version 1.0.0
 * @date 2024/03/20
 * @className java.lang.String
 */
public class ViewPagerItemViewModel extends ItemViewModel<AdvertViewModel> {
    public SingleLiveEvent<AdvertBean> bean = new SingleLiveEvent<>();
    public SingleLiveEvent<Drawable> bitmap = new SingleLiveEvent<>();

    public ViewPagerItemViewModel(@NonNull AdvertViewModel viewModel, Drawable bitmap) {
        super(viewModel);
        this.bitmap.postValue(bitmap);
    }

    public ViewPagerItemViewModel(@NonNull AdvertViewModel viewModel, AdvertBean bean) {
        super(viewModel);
//        KLog.e(bean.toString());
        this.bean.postValue(bean);
        this.bitmap.postValue(bean.getDrawable());
    }

    /**
     * 在项目上单击
     */
    public BindingCommand onItemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            //点击之后将逻辑转到activity中处理
            viewModel.ui.itemClickEvent.setValue(bean);
        }
    });
}
